package com.zb_study.Homework05;

public class Person {
    private String name;
    private Vehicles vehicles;

    public Person(String name, Vehicles vehicles) {
        this.name = name;
        this.vehicles = vehicles;
    }

    public void passRiver() {
       if(!(vehicles instanceof Boat)) {
           vehicles = factory.getBoat();
       }
       vehicles.work();
    }

    public void common() {
        if (!(vehicles instanceof Horse)) {
           vehicles = factory.getHorse();
        }
        vehicles.work();
    }
}
